package com.coocaa.x.service.liteservice;

import android.content.ComponentName;
import android.content.Context;
import android.os.IBinder;

import com.coocaa.x.framework.utils.LogUtils;
import com.coocaa.x.service.XServiceManager.XServiceConnection;
import com.coocaa.x.service.liteservice.aidl.ILiteEntryService;

public class LiteEntryServiceConnecter extends XServiceConnection<ILiteEntryService> {
    private static final String ACTION = "com.coocaa.x.service.liteentry";
    private static final String CLASS_NAME = "com.coocaa.x.service.liteservice.LiteEntryService";

    public static final ComponentName getComponentName(Context context) {
        return new ComponentName(context, CLASS_NAME);
    }

    public static final LiteEntryServiceConnecter connecter = new LiteEntryServiceConnecter();

    private ILiteEntryService service = null;

    public LiteEntryServiceConnecter() {
        super(ACTION);
    }

    @Override
    public void onServiceConnected(ComponentName name, IBinder s) {
        service = (ILiteEntryService) ILiteEntryService.Stub.asInterface(s);
        super.onServiceConnected(name, s);
    }

    @Override
    public void onServiceDisconnected(ComponentName name) {
        service = null;
        super.onServiceDisconnected(name);
    }

    @Override
    protected String getUsedServicePackage(String action) {
        LogUtils.i("UUUU", ACTION + "   pkgName:" + mContext.getPackageName());
        return mContext.getPackageName();
    }

    @Override
    protected ILiteEntryService _getService() {
        return service;
    }

}